package mdt.figure;

import java.awt.Graphics;

import org.tigris.gef.base.Globals;
import org.tigris.gef.base.PathItemPlacementStrategy;
import org.tigris.gef.base.SelectionReshape;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigEdge;

public class SelectionEdgeClarifiers extends SelectionReshape {


    /**
     * Construct a new SelectionEdgeClarifiers for the given Fig
     *
     * @param f the given fig
     */
    public SelectionEdgeClarifiers(Fig f) {
        super(f);
    }

    /**
     * This extends the standard selection painting to also highlight
     * the editable text labels and their placement strategies should
     * there be only one selected item.
     *
     * @param g the graphics object
     * @see org.tigris.gef.base.Selection#paint(java.awt.Graphics)
     */
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        int selectionCount =
                Globals.curEditor().getSelectionManager().getSelections().size();
        if (selectionCount == 1) {
            FigEdge edge = (FigEdge) getContent();
            for (PathItemPlacementStrategy strategy
                    : edge.getPathItemStrategies()) {
                strategy.paint(g);
            }
        }
    }

}
